#pragma once

template<typename T,unsigned n,unsigned m>
class matrix{

	T a[n][m];

public:
	
	T* operator[]( unsigned i ){

		return a[i];

	}

	matrix operator+( const matrix& m_ ){

		matrix temp;
		unsigned i,j;
		for(i=0;i<n;i++){

			for(j=0;j<m;j++)
				temp.a[i][j]=this->a[i][j]+m_.a[i][j];

		}

	}

	void operator+=( const matrix& m_ ){

		unsigned i,j;
		for(i=0;i<n;i++){

			for(j=0;j<m;j++)
				this->a[i][j]+=m_.a[i][j];

		}

	}

	matrix operator-( const matrix& m_ ){

		matrix temp;
		unsigned i,j;
		for(i=0;i<n;i++){

			for(j=0;j<m;j++)
				temp.a[i][j]=this->a[i][j]-m_.a[i][j];

		}

	}
	
	void operator-=( const matrix& m_ ){

		unsigned i,j;
		for(i=0;i<n;i++){

			for(j=0;j<m;j++)
				this->a[i][j]-=m_.a[i][j];

		}

	}

	template<typename T,unsigned l>
	matrix<T,n,l> operator*( const matrix<T,m,l>& m_ ){

		matrix temp;
		unsigned i,j,k;
		for(i=0;i<n;i++){

			for(j=0;j<l;j++){

				for(k=0;k<m;k++)
					temp.a[i][j]+=temp.a[i][k]*temp.a[k][j];

			}

		}

		return temp;

	}	

};
